import 'package:flutter/material.dart';
import 'package:flutter_learning/tableview/src/datas/m_column.dart';
import 'package:flutter_learning/tableview/src/datas/m_row.dart';
import 'package:flutter_learning/tableview/src/datas/merge_table_alignment.dart';
import 'package:flutter_learning/tableview/src/merge_table.dart';

class LYTableView extends StatefulWidget {
  const LYTableView({super.key});

  @override
  State<LYTableView> createState() => _LYTableViewState();
}

class _LYTableViewState extends State<LYTableView> {
  @override
  Widget build(BuildContext context) {
    return MergeTable(
      borderColor: Colors.black,
      alignment: MergeTableAlignment.center,
      rowHeight: 80,
      columns: [
        MColumn(header: "Pump"),
        MColumn(header: "Product"),
        MColumn(header: "Seal"),
        MMergedColumns(
          header: "Reading",
          columns: ["Before", "Then", "After"],
        ),
        MColumn(header: "Write"),
      ],
      rows: [
        [
          MRow(const Text("1")),
          MRow(const Text("2")),
          MRow(const Text("3")),
          MMergedRows([
            const Text("4"),
            const Text("5"),
            const Text("8"),
          ]),
          MRow(const Text("6")),
        ],
        [
          MRow(const Text("1")),
          MRow(const Text("2")),
          MRow(const Text("3")),
          MMergedRows([
            const Text("4"),
            const Text("5"),
            const Text("8"),
          ]),
          MRow(const Text("6")),
        ],
      ],
    );
    // return Table(
    //   columnWidths: {
    //     0: FixedColumnWidth(100),
    //     1: FixedColumnWidth(100),
    //     2: FixedColumnWidth(100),
    //     3: FixedColumnWidth(100)
    //   },
    //   children: [
    //     TableRow(
    //         decoration: BoxDecoration(
    //             border: Border.all(color: Colors.black, width: 1)),
    //         children: [
    //           Container(
    //             height: 50,
    //             alignment: Alignment.center,
    //             child: Text('1'),
    //           ),
    //           VerticalDivider(
    //             width: 1,
    //             color: Colors.black,
    //           ),
    //           Expanded(
    //             child: Container(
    //               height: 50,
    //               alignment: Alignment.center,
    //               child: Text('1'),
    //             ),
    //           ),
    //         ]),
    //     TableRow(
    //         // decoration: BoxDecoration(
    //         //     border: Border.all(color: Colors.black, width: 1)),
    //         children: [
    //           Container(
    //             height: 50,
    //             alignment: Alignment.center,
    //             child: Text('1'),
    //           ),
    //           VerticalDivider(
    //             width: 1,
    //             color: Colors.black,
    //           ),
    //           Expanded(
    //             child: Container(
    //               height: 50,
    //               alignment: Alignment.center,
    //               child: Text('1'),
    //             ),
    //           ),
    //         ]),
    //   ],
    // );
  }

  Widget _makeDataTable() {
    return DataTable(border: TableBorder.all(color: Colors.black, width: 1), columns: [
      DataColumn(label: Text('1')),
      DataColumn(label: Text('1')),
      DataColumn(label: Text('1')),
      DataColumn(label: Text('1'))
    ], rows: [
      DataRow(cells: [
        DataCell(Text('content')),
        DataCell(Text('content')),
        DataCell(Text('content')),
        DataCell(Text('content')),
      ])
    ]);
  }
}
